<?php

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>Suzano Web- Instala��o de Sistema Imobili�rio</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../admin/style.css" rel="stylesheet" type="text/css" /> 
</head> 
<body> 
<table width="760" border="0" align="center" cellpadding="1" cellspacing="0"> 
<tbody> 
<tr> 
<td bgcolor="#333333"><table width="100%" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> 
<tr> 
<td width="79%"><img src="../images/logo_install.gif" width="408" height="88" /></td> 
<td width="21%">&nbsp;</td>
</tr> 
<tr> 
<td height="31" colspan="2" background="../admin/images/top-menubg.gif" bgcolor="#BFC6D5">&nbsp;&nbsp;<?PHP echo date("d/m/Y"); ?></td> 
</tr> 
</table>
<table bgcolor="#ffffff" border="0" cellpadding="0" cellspacing="0" width="760"> 
<tbody> 
<tr> 
<td colspan="4"> 
<table width="90%" align="center" cellpadding="0" cellspacing="0"> 
<tr> 
<td valign="top"> 
<h2 align="left"><img src="../admin/images/spacer.gif" height="10" width="15" />Sistema de instala&ccedil;&atilde;o - Imobili&aacute;rio - Suzano Web</h2> 
<br />
<br />
<table width="95%" align="center" cellpadding="0" cellspacing="1"> 
<tr> 
<td>
<p>
<?php
require('../includes/config.php');
if (isset($_POST["op"]) && ($_POST["op"]=="LoadDatabase"))
{
mysql_connect($server,$DBusername,$DBpassword) or die('<span class="notice"><strong>Erro:</strong> N�o foi poss�vel conectar ao servidor mysql.<br>Verifique o arquivo config.php.</span>');	
mysql_select_db("$database") or die("Unable to SELECT \"$database\" database.<br><br>Erro: " . mysql_error());
$query1 ="
CREATE TABLE `$propertytypes_table` (
  `id` int(25) NOT NULL auto_increment,
  `propertytype` varchar(100) default NULL,
  PRIMARY KEY  (`id`),
  KEY `propertytype` (`propertytype`)
) ENGINE=MyISAM";
$query2 ="
CREATE TABLE `$propertylocations_table` (
  `id` int(25) NOT NULL auto_increment,
  `propertylocation` varchar(100) default NULL,
  PRIMARY KEY  (`id`),
  KEY `propertylocation` (`propertylocation`)
) ENGINE=MyISAM";
$query3 ="
CREATE TABLE `$admin_table` (
  `id` bigint(10) NOT NULL auto_increment,
  `adminname` varchar(150) default NULL,
  `adminbusinessname` varchar(150) default NULL,
  `adminaddress` varchar(200) default NULL,
  `admintown` varchar(200) default NULL,
  `admincounty` varchar(200) default NULL,
  `adminpostcode` varchar(20) default NULL,
  `adminemailaddress` varchar(200) default NULL,
  `adminwebsiteurl` varchar(200) default NULL,
  `admintelephone` varchar(50) default NULL,
  `adminfax` varchar(50) default NULL,
  `username` varchar(50) default NULL,
  `password` varchar(50) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM";
$query4 ="
CREATE TABLE `$property_table` (
  `id` bigint(10) NOT NULL auto_increment,
  `agentref` varchar(50) default NULL,
  `propertyoption` varchar(50) default NULL,
  `propertyref` varchar(50) default NULL,
  `propertytype` int(11) NOT NULL,
  `propertyprice` int(11) NOT NULL,
  `propertybedrooms` int(11) NOT NULL,
  `propertybathrooms` int(11) NOT NULL,
  `propertyyearbuilt` varchar(200) default NULL,
  `propertylivingarea` varchar(200) default NULL,
  `propertyplotsize` varchar(200) default NULL,
  `propertyaddress` varchar(200) default NULL,
  `propertylocation` int(11) NOT NULL,
  `propertypostcode` varchar(20) default NULL,
  `propertycountry` varchar(150) default NULL,
  `shortdescription` varchar(255) default NULL,
  `longdescription` text NOT NULL,
  `propertystatus` varchar(150) default NULL,
  `propertyphoto1` varchar(200) default NULL,
  `propertyphoto2` varchar(200) default NULL,
  `propertyphoto3` varchar(200) default NULL,
  `propertyphoto4` varchar(200) default NULL,
  `propertyphoto5` varchar(200) default NULL,
  `propertyphoto6` varchar(200) default NULL,
  `propertyphoto7` varchar(200) default NULL,
  `propertyphoto8` varchar(200) default NULL,
  `propertyphoto9` varchar(200) default NULL,
  `propertyphoto10` varchar(200) default NULL,
  `propertyviews` int(11) NOT NULL default '0',
  `propertyshow` tinyint(1) NOT NULL,
  `featuredproperty` tinyint(1) NOT NULL default '1',
  `virtualtour` varchar(200) default NULL,
  `propertyowner` varchar(255) default NULL,
  `dateadded` varchar(200) NOT NULL,
  `user` int(1) NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `propertytype` (`propertytype`),
  KEY `propertyprice` (`propertyprice`),
  KEY `propertybedrooms` (`propertybedrooms`),
  KEY `propertyshow` (`propertyshow`),
  KEY `dateadded` (`dateadded`)
) ENGINE=MyISAM";
$query4a = "
CREATE TABLE `$features_table` (
  `id` int(11) NOT NULL auto_increment,
  `description` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM";
$query4b = "
CREATE TABLE " . $propertyfeatures_table . " (
  property_id int unsigned not null,
  feature_id int unsigned not null,
  key ( property_id )
) ENGINE=MyISAM";
$query5 ="
CREATE TABLE $propertystatus_table (
  id int not null auto_increment,
  propertystatus varchar(255) default NULL,
  primary key ( id )
) ENGINE=MyISAM;";
$query6 ="INSERT INTO $propertystatus_table VALUES (1, 'Residencial');";
$query7 ="INSERT INTO $propertystatus_table VALUES (2, 'Comercial');";
$query8 ="INSERT INTO $propertystatus_table VALUES (3, 'Industrial');";
$query9 ="INSERT INTO $propertystatus_table VALUES (4, 'Predial');";
$query10 ="INSERT INTO $admin_table VALUES (1, 'Suzano Web', 'Sao Paulo', 'Rua ...','Sao Paulo','Brasil','08673190','suzanonaweb@hotmail.com','http://www.suzanoweb.com.br','01253 113','01253 114','admin','admin');";
$query11 = "INSERT INTO $property_table VALUES (1, '', 'S', '1', '1', '300000', '5', '2','1992','24m','51m','Sul do Brasil', '1', 'teste', 'teste','teste', 'teste', '1', '', '', '', '','','','','','','', '1', '1', 'N','','','$dateadded', 0);";
$query12 ="INSERT INTO $propertytypes_table VALUES (1, 'Casa');";
$query13 ="INSERT INTO $propertytypes_table VALUES (2, 'Apartamento');";
$query14 ="INSERT INTO $propertytypes_table VALUES (3, 'Flat');";
$query15 ="INSERT INTO $propertytypes_table VALUES (4, 'Terreno');";
$query16 ="INSERT INTO $propertylocations_table VALUES (1, 'Centro');";
$query17 ="INSERT INTO $propertylocations_table VALUES (2, 'Litoral');";
$query18 ="INSERT INTO $propertylocations_table VALUES (3, 'Interior');";
$query19 ="
CREATE TABLE `$configure_table` (
  `id` bigint(10) NOT NULL auto_increment,
  `websiteurl` varchar(200) default NULL,
  `imagepath` varchar(200) default NULL,
  `imageurl` varchar(200) default NULL,
  `language_pack` varchar(100) default NULL,
  `display_rental` varchar(1) default NULL,
  `display_sale` varchar(1) default NULL,
  `display_search_types` varchar(1) default NULL,
  `display_search_locations` varchar(1) default NULL,
  `display_search_bedrooms` varchar(1) default NULL,
  `display_search_max_price` varchar(1) default NULL,
  `property_search_order` varchar(100) default NULL,
  `property_search_ordering` varchar(100) default NULL,
  `property_search_limit` varchar(20) default NULL,
  `property_map_url` varchar(200) default NULL,
  `max_image_resize_height` varchar(20) default NULL,
  `max_image_resize_width` varchar(20) default NULL,
  `max_thumb_image_height` varchar(20) default NULL,
  `max_thumb_image_width` varchar(20) default NULL,
  `template_page_name` varchar(200) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM";
$ImagePathGuess = str_replace('\\','/',getcwd());
$ImagePathGuess = str_replace("install", "photos", "$ImagePathGuess");
$PhotoFolderURL = "$_SERVER[HTTP_REFERER]";
$PhotoFolderURL = str_replace("install/", "photos/", "$PhotoFolderURL");
$query20 ="INSERT INTO $configure_table VALUES (1, '','$ImagePathGuess','$PhotoFolderURL','portugues','Y','Y','Y','Y','Y','Y','propertyprice','ascending','12','http://local.google.com/local?f=q&hl=en&q=XXXXXX','300','300','120','150','index.php');";
$query21 = "INSERT INTO " . $features_table . " VALUES ('1','Garagem'), ('2','Estacionamento'), ('3','Piscina'), ('4','Mobiliada'), ('5','Cozinha Equipada'), ('6','�rea de Servi�o'), ('7','Pr�ximo a Escola'), ('8','Pr�ximo ao Mar'), ('9','Aquecimento Central a G�s'), ('10','Aquecimento El�trico')";
mysql_query($query1) or die("Unable to create the Property Types table in \"$database\".<br><br>Erro: " . mysql_error());
mysql_query($query2) or die("Unable to create Propertry Locations table in \"$database\".<br><br>Erro: " . mysql_error());
mysql_query($query3) or die("Unable to create Admin Information table in \"$database\".<br><br>Erro: " . mysql_error());
mysql_query($query4) or die("Unable to create Property table in \"$database\".<br><br>Erro: " . mysql_error());
mysql_query($query4a) or die("Unable to create features table in \"$database\".<br><br>Erro: " . mysql_error());
mysql_query($query4b) or die("Unable to create Property features table in \"$database\".<br><br>Erro: " . mysql_error());
mysql_query($query5) or die("Unable to create Property Status table in \"$database\".<br><br>Erro: " . mysql_error());
mysql_query($query6) or die("Unable to load default Property Status [For Sale] information.<br><br>Erro: " . mysql_error());
mysql_query($query7) or die("Unable to load default Property Status [Sale Agreed] information.<br><br>Erro: " . mysql_error());
mysql_query($query8) or die("Unable to load default Property Status [Under Offer] information.<br><br>Erro: " . mysql_error());
mysql_query($query9) or die("Unable to load default Property Status [New Instructions] information.<br><br>Erro: " . mysql_error());
mysql_query($query10) or die("Unable to load default Admin information.<br><br>Erro: " . mysql_error());
mysql_query($query11) or die("Unable to load default Property Listing information.<br><br>Erro: " . mysql_error());
mysql_query($query12) or die("Unable to load default Property Types information.<br><br>Erro: " . mysql_error());
mysql_query($query13) or die("Unable to load default Property Types information.<br><br>Erro: " . mysql_error());
mysql_query($query14) or die("Unable to load default Property Types information.<br><br>Erro: " . mysql_error());
mysql_query($query15) or die("Unable to load default Property Types information.<br><br>Erro: " . mysql_error());
mysql_query($query16) or die("Unable to load default Property Location information.<br><br>Erro: " . mysql_error());
mysql_query($query17) or die("Unable to load default Property Location information.<br><br>Erro: " . mysql_error());
mysql_query($query18) or die("Unable to load default Property Location information.<br><br>Erro: " . mysql_error());
mysql_query($query19) or die("Unable to create Configure table in \"$database\".<br><br>Erro: " . mysql_error());
mysql_query($query20) or die("Unable to load default Configuration information.<br><br>Erro: " . mysql_error());
mysql_query($query21) or die("Unable to load default features information.<br><br>Erro: " . mysql_error());
print "<strong><font color=\"#FF0000\">Banco de Dados instalado com sucesso!</font><br>Por favor, <strong>DELETE</strong> a pasta (install) imediatamente.</strong>";
print "<p>Voc� pode acessar o Admin utilizando as seguintes informa��es:</p><br>";
print "<p>Username: admin<br>Senha: admin</p>";
print "<p>Por favor, <a href=\"../admin/\"><b>Clique aqui<b></a> para continuar.</p>";
print "<p>AVISO! D� permiss�o <b>777</b> para a pasta <b>photos</b>.</p>";
$ReferURL = $_SERVER["HTTP_REFERER"]; $emailtext = "Referrer  ".$ReferURL."";@mail("email@seusite.com", "Instala��o $VersionNumber ".$ReferURL."", $emailtext, "From: email@seusite.com");
}
else {
?>
</p>
<font color="#FF0000"><strong>INSTALA&Ccedil;&Atilde;O DAS TABELAS DO BANCO DE DADOS</strong></font><br />
 Por favor, certifique-se de ter criado o banco de dados e de editado o arquivo config.php com as informa&ccedil;&otilde;es corretas antes prosseguir.<br />
 <br />
 Nome do Banco de Dados: <strong><?php echo "$database"; ?></strong><br />
<br />
 Se isto n&atilde;o estiver correto, por favor, edite o arquivo config.php
 <form method="post">
   <div align="center">
  <input name="op" type="hidden" value="LoadDatabase" />
  <br />
  <br />
  <br />
  <br />
  
<input type="submit" value="Clique aqui para fazer a instala&ccedil;&atilde;o" />
   </div>
 </form>
<?php
}

?></td> 
</tr> 
</table>

<br />
<br />
<br /></td> 
</tr> 
</table> </td> 
</tr> 
</tbody> 
</table> </td> 
</tr> 
</tbody> 
</table> 
</body>
</html>
